package com.yikome.product.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.yikome.common.CommonRepository;
import com.yikome.product.entity.ProductAttributeValue;

@Repository
public interface ProductAttributeValueRepository extends CommonRepository<ProductAttributeValue, Long> {

	@Query("select pav from ProductAttributeValue pav where pav.yn = 1 and pav.productAttributeId = :productAttributeId order by pav.priority asc")
	List<ProductAttributeValue> findByProductAttributeId(@Param("productAttributeId")Long productAttributeId);

	@Query("select p from  ProductAttributeValue p where productId = :productId and productAttributeId = :productAttributeId and yn = 1 order by priority asc")
	List<ProductAttributeValue> findAllProductAttributeValue(@Param("productId") Long productId, @Param("productAttributeId") Long productAttributeId);
	
	void deleteByProductIdAndProductAttributeId(Long productId , Long productAttributeId);

	void deleteByProductId(Long productId);

}
